<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->string('order_sn', 100)->comment('订单号');
            $table->integer('server_id')->comment('游戏服id');
            $table->bigInteger('userid')->comment('账号id');
            $table->bigInteger('player_id')->comment('角色id');
            $table->string('player_name')->comment('角色名称');
            $table->integer('amount')->default(0)->comment('订单金额');
            $table->integer('platform_id')->comment('平台id');
            $table->integer('channel_id')->nullable()->comment('渠道id');
            $table->string('serial')->comment('支付流水号');
            $table->integer('pay_time')->comment('支付时间');
            $table->string('platform_order_sn', 50)->comment('平台订单号');
            $table->tinyInteger('status')->comment('订单状态0未支付1已支付');
            $table->integer('order_time')->comment('下单时间');
            $table->string('desc')->comment('备注');
            $table->integer('payWay')->comment('支付方式');
            $table->smallInteger('charge_level')->default(0)->comment('充值档位');
            $table->timestamps();
            $table->softDeletes();
            $table->unique('order_sn');
            $table->index('player_id');
            $table->index(['status', 'player_name']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
